def saveToFile(content, fileName):
    import os.path
    dir = os.path.split(fileName)[0]
    try:
        os.makedirs(dir)
    except:
        pass
    f = open(fileName, 'w')
    f.write(content)
    f.close()

def loadFromFile(fileName):
    f = open(fileName)
    s = f.read()
    f.close()
    return s

def month2Int(month):
    dic = {'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6, 'July':7, 'August':8, 'September':9, 'October':10, 'November':11, 'December':12}
    return dic[month]

def copyFile(src, tgt):
    import os.path
    import shutil
    dir = os.path.split(tgt)[0]
    try:
        os.makedirs(dir)
    except:
        pass
    shutil.copyfile(src, tgt)

def string2date(date_string):
    from datetime import datetime
    return datetime.strptime(date_string, "%Y-%m-%d").date()
    
def date2string(date):
    return date.isoformat()